'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const p = require('../doc/applyReviver.cjs'),
  c = require('./identity.cjs'),
  f = require('./toJS.cjs');
class y {
  constructor(e) {
    Object.defineProperty(this, c.NODE_TYPE, { value: e });
  }
  clone() {
    const e = Object.create(
      Object.getPrototypeOf(this),
      Object.getOwnPropertyDescriptors(this),
    );
    return this.range && (e.range = this.range.slice()), e;
  }
  toJS(e, { mapAsMap: i, maxAliasCount: r, onAnchor: o, reviver: s } = {}) {
    if (!c.isDocument(e))
      throw new TypeError('A document argument is required');
    const n = {
        anchors: new Map(),
        doc: e,
        keep: !0,
        mapAsMap: i === !0,
        mapKeyWarned: !1,
        maxAliasCount: typeof r == 'number' ? r : 100,
      },
      t = f.toJS(this, '', n);
    if (typeof o == 'function')
      for (const { count: a, res: u } of n.anchors.values()) o(u, a);
    return typeof s == 'function' ? p.applyReviver(s, { '': t }, '', t) : t;
  }
}
exports.NodeBase = y;
